//
//  VerifiedController.m
//  Youhuiju
//
//  Created by liuovyue on 16/8/11.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "VerifiedController.h"
#import <objc/runtime.h>
#import "VerifiedTwoController.h"

@interface VerifiedController ()

@property (nonatomic, strong)UILabel *labelTitle;
@property (nonatomic, strong)UIButton *buttonReturn;
@property (nonatomic, strong)UIView *viewBar;
@property (strong, nonatomic) IBOutlet UIView *viewTwoBackgrond;
@property (strong, nonatomic) IBOutlet UILabel *labelCheck;
//请填写您的真实信息,通过审核后将不能修改
@property (strong, nonatomic) IBOutlet UILabel *labelPleaseWrite;
//uiview
@property (strong, nonatomic) IBOutlet UIView *viewBackgrondWrite;
//实名认证后,您的账户将得到更完善的保护,投资支付更安全
@property (strong, nonatomic) IBOutlet UILabel *labelVerified;
//实名认证优势
@property (strong, nonatomic) IBOutlet UILabel *labelAdvantage;
//保护账户安全
@property (strong, nonatomic) IBOutlet UILabel *labelProtect;
//专属优惠
@property (strong, nonatomic) IBOutlet UILabel *labelPreferential;
//支付更便捷
@property (strong, nonatomic) IBOutlet UILabel *labelPay;
//下一步
@property (strong, nonatomic) IBOutlet UIButton *buttonNext;
//真实姓名
@property (strong, nonatomic) IBOutlet UITextField *textFieldName;
//身份证号
@property (strong, nonatomic) IBOutlet UITextField *textFieldidCard;
@property (strong, nonatomic) IBOutlet UILabel *labelID;
@property (strong, nonatomic) IBOutlet UILabel *labelName;

@end

@implementation VerifiedController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.labelID.font = [UIFont systemFontOfSize:14*FitW];
    self.labelName.font = [UIFont systemFontOfSize:14*FitW];
    self.labelCheck.textColor = [UIColor colorWithHexString:@"999999"];
    self.viewTwoBackgrond.backgroundColor = [UIColor colorWithHexString:@"eeeeee"];
    [self createNavigationBar];
    self.labelPleaseWrite.font = [UIFont systemFontOfSize:11*FitW];
    self.labelPleaseWrite.textColor = [UIColor colorWithHexString:@"999999"];
    self.viewBackgrondWrite.backgroundColor = [UIColor colorWithHexString:@"eeeeee"];
    self.labelVerified.font = [UIFont systemFontOfSize:11*FitW];
    self.labelVerified.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelAdvantage.font = [UIFont systemFontOfSize:15*FitW];
    self.labelAdvantage.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelProtect.font = [UIFont systemFontOfSize:12*FitW];
    self.labelProtect.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelPay.font = [UIFont systemFontOfSize:12*FitW];
    self.labelPay.textColor = [UIColor colorWithHexString:@"999999"];
    self.labelPreferential.font = [UIFont systemFontOfSize:12*FitW];
    self.labelPreferential.textColor = [UIColor colorWithHexString:@"999999"];
    
    self.buttonNext.backgroundColor = [UIColor colorWithHexString:@"ff5f7b"];

    
    //self.textFieldName.text = @"刘晓晨";
    //self.textFieldidCard.text = @"1234";
    


}

- (void)createNavigationBar{
    
    self.viewBar = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64)];
    self.viewBar.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.viewBar];
    
    
    
   
    
    
    self.labelTitle = [[UILabel alloc]init];
    self.labelTitle.text = @"实名认证";
    self.labelTitle.textAlignment = NSTextAlignmentCenter;
   
    self.labelTitle.font = [UIFont systemFontOfSize:18*FitW];
    [self.viewBar addSubview:self.labelTitle];
    
    [_labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        //make.top.equalTo(self.viewBar.mas_top);
        make.left.equalTo(self.viewBar.mas_left).offset(100*FitW);
        make.right.equalTo(self.viewBar.mas_right).offset(-100*FitW);
        make.bottom.equalTo(self.viewBar.mas_bottom).offset(-14*FitH);
        
        
        
    }];
    //返回按钮
    self.buttonReturn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.buttonReturn setImage:[UIImage imageNamed:@"zfanhuijian"] forState:UIControlStateNormal];
    [self.buttonReturn addTarget:self action:@selector(tuihuiAcion:) forControlEvents:UIControlEventTouchUpInside];
    [self.viewBar addSubview:self.buttonReturn];
    
    [_buttonReturn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.viewBar.mas_left).offset(17*FitW);
        make.width.mas_equalTo(22*FitW);
        make.height.mas_equalTo(22*FitH);
        make.bottom.equalTo(self.viewBar.mas_bottom).offset(-13*FitH);
        
        
        
    }];
    
    
    
}
- (void)tuihuiAcion:(UIButton *)button {
    

    [self.navigationController popViewControllerAnimated:YES];




}
- (IBAction)nextPageAction:(id)sender {
    
    
    if ([self.textFieldName.text isEqualToString: @"1234"]) {
        
    

    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"输入真实身份已被占用若身份属于您本人,请申诉找回" message:nil preferredStyle:UIAlertControllerStyleAlert];
   
    alertController.view.tintColor = [UIColor redColor];

    
    
   [self presentViewController:alertController animated:YES completion:nil];

    
   
    [alertController addAction: [UIAlertAction actionWithTitle: @"申诉找回" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        NSLog(@"申诉找回");
    }]];
   
    [alertController addAction: [UIAlertAction actionWithTitle: @"更改信息" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action){
        NSLog(@"更改信息");
    }]];
    }else {
        
        VerifiedTwoController *verified = [[VerifiedTwoController alloc]initWithNibName:@"VerifiedTwoController" bundle:nil];
        [self.navigationController pushViewController:verified animated:YES];
        
        
    }
    
}



//获得所有变量
- (NSArray *)getAllIvar:(id)object
{
    NSMutableArray *array = [NSMutableArray array];
    
    unsigned int count;
    Ivar *ivars = class_copyIvarList([object class], &count);
    for (int i = 0; i < count; i++) {
        Ivar ivar = ivars[i];
        const char *keyChar = ivar_getName(ivar);
        NSString *keyStr = [NSString stringWithCString:keyChar encoding:NSUTF8StringEncoding];
        @try {
            id valueStr = [object valueForKey:keyStr];
            NSDictionary *dic = nil;
            if (valueStr) {
                dic = @{keyStr : valueStr};
            } else {
                dic = @{keyStr : @"值为nil"};
            }
            [array addObject:dic];
        }
        @catch (NSException *exception) {}
    }
    return [array copy];
}

//获得所有属性
- (NSArray *)getAllProperty:(id)object
{
    NSMutableArray *array = [NSMutableArray array];
    
    unsigned int count;
    objc_property_t *propertys = class_copyPropertyList([object class], &count);
    for (int i = 0; i < count; i++) {
        objc_property_t property = propertys[i];
        const char *nameChar = property_getName(property);
        NSString *nameStr = [NSString stringWithCString:nameChar encoding:NSUTF8StringEncoding];
        [array addObject:nameStr];
    }
    return [array copy];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
